package com.ay277.htqoa.base.controller;

import com.ay277.htqoa.base.biz.UserBiz;
import com.ay277.htqoa.base.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

/**
 * Created by accp09 on 2016/12/9.
 */
@Controller
public class UserController{
    @Autowired
    private UserBiz userBiz;
    private  User user;

    public UserBiz getUserBiz() {
        return userBiz;
    }

    public void setUserBiz(UserBiz userBiz) {
        this.userBiz = userBiz;
    }

    @RequestMapping("/addUser")
    public String AddUser(User user){
        user.setCreateTime(new Date());
        userBiz.doSave(user);
        return "login";
    }
    @RequestMapping("/loginUser")
    public String login(String userid,String pwd,ModelMap map){
        User user = userBiz.findUser(userid,pwd);
        map.addAttribute("user",user);
        if(user!=null) {
            return "ok";
        }else {
            return"login";
        }
    }
}
